function img = DrawThickColorRGBBox(v, xmin, ymin, xmax, ymax, r, g, b, thickness, xlimit, ylimit)

diff = floor((thickness-1)/2.0);

if diff == 0
    diff = 1;
    xmin1 = xmin;
    xmin2 = xmin + diff;
    xmax1 = xmax;
    xmax2 = xmax + diff;

    ymin1 = ymin;
    ymin2 = ymin + diff;
    ymax1 = ymax;
    ymax2 = ymax + diff;
else
    xmin1 = xmin - diff;
    xmin2 = xmin + diff;
    xmax1 = xmax - diff;
    xmax2 = xmax + diff;

    ymin1 = ymin - diff;
    ymin2 = ymin + diff;
    ymax1 = ymax - diff;
    ymax2 = ymax + diff;
end

if xmin1 < 1
    xmin1 = 1;
end

if xmax2 > xlimit
    xmax2 = xlimit;
end

if ymin1 < 1
    ymin1 = 1;
end

if ymax2 > ylimit
    ymax2 = ylimit;
end


for i = xmin1:xmax2
    v(i,ymin1:ymin2,1) = r;
    v(i,ymax1:ymax2,1) = r;
    v(i,ymin1:ymin2,2) = g;
    v(i,ymax1:ymax2,2) = g;
    v(i,ymin1:ymin2,3) = b;
    v(i,ymax1:ymax2,3) = b;
end

for j = ymin1:ymax2
    v(xmin1:xmin2,j,1) = r;        
    v(xmax1:xmax2,j,1) = r;        
    v(xmin1:xmin2,j,2) = g;        
    v(xmax1:xmax2,j,2) = g;        
    v(xmin1:xmin2,j,3) = b;        
    v(xmax1:xmax2,j,3) = b;        
end

img = v;